<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>法定假期信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<div style="margin: 10px">
    <table id="sysVacationTable" lay-filter="sysVacationTable"></table>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="sysVacationHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="delete">
                <i class="layui-icon layui-icon-delete"></i>
                <span>删除</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="sysVacationQueryForm" style="margin-right: 30px;">
            <div class="layui-row" style="margin-top: 10px;">
                <div class="selch table-top-filter">
                    <div class="table-filter-alone">
                        <label class="layui-form-label">假日名称</label>
                        <input type="text" class="layui-input filter-value" name="Q_name_SL" placeholder="假日名称"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">年份</label>
                        <input type="text" class="layui-input filter-value" name="Q_years_N" placeholder="年份"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">开始时间</label>
                        <input type="text" class="layui-input start_time filter-value" name="Q_beginStartTime_DL" placeholder="开始时间"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">结束时间</label>
                        <input type="text" class="layui-input end_time filter-value" name="Q_endEndTime_DG" placeholder="结束时间"/>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="sysVacationRightToolsBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'setter', 'form', 'common','totalFilter','commons','jquery'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var commons = layui.commons;
        var $ = layui.jquery;
        var totalFilter = layui.totalFilter;
        common.tableSort('sysVacationTable');

        var tableH=commons.tabHeight('full-70');

        //第一个实例
        table.render({
            elem: '#sysVacationTable'
            ,height:tableH
            ,url: serverPath.basePath + '/system/sysVacation/list'
            ,page: true //开启分页
            ,defaultToolbar: ['filter', 'print']
            ,toolbar: '#sysVacationHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                ,{type: 'checkbox', fixed: 'left'}
                ,{field: 'id', title: '主键id',hide:true,sort:true, sortname: 'id'}
                ,{field: 'name', title: '假日名称',sort:true, sortname: 'name'}
                ,{field: 'years', title: '年份',sort:true, sortname: 'years'}
                //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.startTime,"1");
                //如需转换为HH:mm:ss: return commons.timeData(d.startTime,"2");
                // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.startTime);
                ,{field: 'startTime', title: '开始时间',sort:true, sortname: 'starttime',templet: function (d) {
                    return commons.timeData(d.startTime);
                }}
                //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.endTime,"1");
                //如需转换为HH:mm:ss: return commons.timeData(d.endTime,"2");
                // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.endTime);
                ,{field: 'endTime', title: '结束时间',sort:true, sortname: 'endtime',templet: function (d) {
                    return commons.timeData(d.endTime);
                }}
                ,{field: 'dataId', title: 'dataId',hide:true,sort:true, sortname: 'dataId'}
                ,{
                    fixed: 'right',
                    align: 'center',
                    title: '管理',
                    toolbar: '#sysVacationRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });

        totalFilter.init('sysVacationTable');
        commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);

        function reflashQuery(isClear) {
            common.tableConditionRender("sysVacationTable","sysVacationQueryForm",{where:{}},isClear);
        }

        table.on('toolbar(sysVacationTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    $(this).attr("href", serverPath.systemPath+setter.sysLinkPath+"sysVacation/view/add");
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].dataId+",";
                    }
                    delFun(data,array);
                    break;
                case "query":
                    reflashQuery(false);
                    commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);
                    break;
                case "clears":
                    reflashQuery(true);
                    commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);
                    break;

            };
        });

        table.on('tool(sysVacationTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    $(this).attr("href", serverPath.systemPath+setter.sysLinkPath+"sysVacation/view/add?dataId="+data.dataId);
                    break;
                case "del":
                    delFun(data,data.dataId);
                    break;
            }
        });

        function delFun(data,dataId) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!');
            } else {
                layer.confirm('确定删除当前数据吗?', function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.basePath + setter.sysLinkPath + "sysVacation/del",
                        type: "post",
                        data: {dataId:dataId},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            commons.reflashDate({startName:'.start_time',endName:'.end_time'},'',true);
        };
        common.tableSort("sysVacationTable",{show:window.Initialization});
    });
</script>
<style>
    .layui-table-tool-temp {
    padding-right: 0px;
}
</style>

</body>
</html>

